package com.yutel.tool.zip;

import com.yutel.tool.zip.ZipUtils;

public class ZipCmd {
	public static final String TYPE_ZIP = "zip";
	public static final String TYPE_UNZIP = "unzip";

	public static void command(String[] args) throws Exception {
		String type = args[0];
		String src = null;
		String dest = null;
		if (args.length > 1) {
			src = args[1];
		}
		if (args.length > 2) {
			dest = args[2];
		}
		if (type.equals(TYPE_ZIP)) {
			ZipUtils.zip(src, dest);
		} else if (type.equals(TYPE_UNZIP)) {
			ZipUtils.unZip(src, dest);
		} else {
			System.out.println(args + "is not support command");
			System.out.println(help());
		}
	}

	public static String help() {
		StringBuffer sb = new StringBuffer();
		sb.append("压缩:\tjava -jar spanner.jar zip <path> <file>").append("\n");
		sb.append("解压:\tjava -jar spanner.jar unzip <file> <path>")
				.append("\n");
		return sb.toString();
	}

}
